package org.forex.impl.engine;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CheckInstruments implements Runnable {

	Set<CheckOrder> orders;
	ExecutorService exec=Executors.newFixedThreadPool(4);
	
	public CheckInstruments() {
		orders=new HashSet<CheckOrder>();
	}
	
	public void addCheckOrder(CheckOrder co){
		orders.add(co);
	}
	
	@Override
	public void run() {
		
		//System.out.println("On Check Instruments");
		
		orders.forEach(order->{
			exec.execute(order);
		});
		
	}
	
	public void shutdown(){
		if(!exec.isShutdown())
			exec.shutdownNow();
	}

}
